import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.Font;


public class NursePanel extends JPanel {

	private JButton btnAddPatient;
	private JButton btnDeletePatient;
	private JButton btnEditPatient;
	private JButton btnFindPatient;
	private JButton btnViewSchedule;

	private class ButtonListen implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource().equals(btnAddPatient)){
				btnAddPatient.getParent().firePropertyChange("addPatient", 0, 1);
			}
			else if(e.getSource().equals(btnDeletePatient)){
				btnDeletePatient.getParent().firePropertyChange("deletePatient", 0, 1);
			}
			else if(e.getSource().equals(btnEditPatient)){
				btnEditPatient.getParent().firePropertyChange("editPatient", 0, 1);
			}
			else if(e.getSource().equals(btnFindPatient)){
				btnFindPatient.getParent().firePropertyChange("findPatient", 0, 1);
			}
			else if(e.getSource().equals(btnViewSchedule)){
				btnViewSchedule.getParent().firePropertyChange("viewSchedule", 0, 1);
			}
		}
		
	}
	
	/**
	 * Create the panel.
	 */	
	public NursePanel() {
		setBackground(new Color(240, 240, 240));
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		btnAddPatient = new JButton("Add Patient");
		springLayout.putConstraint(SpringLayout.WEST,
				btnAddPatient, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, 
				btnAddPatient, 140, SpringLayout.WEST, this);
		btnAddPatient.addActionListener(new ButtonListen());
		add(btnAddPatient);
		
		btnDeletePatient = new JButton("Delete Patient");
		springLayout.putConstraint(SpringLayout.WEST,
				btnDeletePatient, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST,
				btnDeletePatient, 140, SpringLayout.WEST, this);
		btnDeletePatient.addActionListener(new ButtonListen());
		add(btnDeletePatient);
		
		btnEditPatient = new JButton("Edit Patient");
		springLayout.putConstraint(SpringLayout.NORTH,
				btnDeletePatient, 4, SpringLayout.SOUTH, btnEditPatient);
		springLayout.putConstraint(SpringLayout.EAST,
				btnEditPatient, 140, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, 
				btnEditPatient, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.NORTH,
				btnEditPatient, 94, SpringLayout.NORTH, this);
		btnEditPatient.addActionListener(new ButtonListen());
		add(btnEditPatient);
		
		btnFindPatient = new JButton("Find Patient");
		springLayout.putConstraint(SpringLayout.NORTH, btnFindPatient, 6, SpringLayout.SOUTH, btnDeletePatient);
		springLayout.putConstraint(SpringLayout.WEST, btnFindPatient, 0, SpringLayout.WEST, btnAddPatient);
		springLayout.putConstraint(SpringLayout.EAST, btnFindPatient, 0, SpringLayout.EAST, btnAddPatient);
		btnFindPatient.addActionListener(new ButtonListen());
		add(btnFindPatient);
		
		JLabel lblAdministrative = new JLabel("Nurse");
		lblAdministrative.setFont(new Font("Pristina", Font.ITALIC, 18));
		lblAdministrative.setHorizontalAlignment(SwingConstants.CENTER);
		springLayout.putConstraint(SpringLayout.NORTH,
				lblAdministrative, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST,
				lblAdministrative, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST,
				lblAdministrative, 139, SpringLayout.WEST, this);
		add(lblAdministrative);
		
		JLabel lblMenu = new JLabel("Menu");
		springLayout.putConstraint(SpringLayout.NORTH, btnAddPatient, 4, SpringLayout.SOUTH, lblMenu);
		springLayout.putConstraint(SpringLayout.EAST, lblMenu, 140, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST,
				lblMenu, 10, SpringLayout.WEST, this);
		lblMenu.setFont(new Font("Pristina", Font.ITALIC, 18));
		springLayout.putConstraint(SpringLayout.NORTH,
				lblMenu, 7, SpringLayout.SOUTH, lblAdministrative);
		lblMenu.setHorizontalAlignment(SwingConstants.CENTER);
		add(lblMenu);
		
		btnViewSchedule = new JButton("View Schedule");
		springLayout.putConstraint(SpringLayout.NORTH, btnViewSchedule, 6, SpringLayout.SOUTH, btnFindPatient);
		springLayout.putConstraint(SpringLayout.WEST, btnViewSchedule, 0, SpringLayout.WEST, btnAddPatient);
		springLayout.putConstraint(SpringLayout.EAST, btnViewSchedule, 130, SpringLayout.WEST, btnAddPatient);
		add(btnViewSchedule);
	}
}
